<style type="text/css">
    .banner .well {
        background: none;
        padding: 0; margin: 0;
    }
    div.banner {
        width: 120px;
        z-index: 99999;
        padding-left: 4px; padding-right: 4px;
        margin: 0;
        text-align: center;
        position: fixed;
        right: 0px;
    }
    
    .affix {
        padding: 0; margin: 0;
    }
</style>

<div class="container banner thumbnail">
    <div class="well" style="padding: 5px;">
            <h5>Opciones</h5>
            <button type="button" class="btn btn-success btn-block"  id="btn_guardar" onclick="goToErrors()" >
                <i class="icon-plus icon-white"></i> Guardar</button>
            <button type="button" class="btn btn-success btn-block" id="btn_modificar" >
                <i class="icon-pencil icon-white"></i> Modificar</button>
            <?php if ($this->clienteArray["Id"]): ?>
                <?php $desc_btn_baja = ($this->clienteArray["Baja"] ? "Levantar Baja" : "Dar Baja") ?>
                <button type="button" class="btn btn-warning btn-block" id="btn_baja" >
                    <i class="icon-eye-close icon-white"></i> <?php echo $desc_btn_baja ?></button>
            <?php endif; ?>
            <button type="button" class="btn btn-danger btn-block" id="btn_eliminar">
                <i class="icon-trash icon-white"></i> Borrar </button>           
            <hr>
            <button type="button" class="btn btn-info btn-block" id="btn_ver_datos_creditos" >
                <i class="icon-th-list icon-white"></i> Datos Creditos</button>
            <?php if (isset($this->session->cliente_id)){ ?>
                <button type="button" class="btn btn-warning" id="btn_continuar_credito" >
                    <i class="icon-forward icon-white"></i> Continuar Con el Credito</button>
            <?php } ?>    
    </div>
</div>

<form style="margin: 0;" id="form-eliminar-cliente" method="GET" action="<?php echo $this->baseUrl("/usuarios/cliente/eliminar/") ?>">
    <input id="borrar_cliente_id" type="hidden" name="cliente_id" value="<?php echo $this->clienteArray["Id"] ?>" />
</form>
<form style="margin: 0;" id="form-ver-creditos-cliente" method="GET" action="<?php echo $this->baseUrl("/usuarios/busqueda/obternerdatospersona/") ?>">
    <input id="b_cliente_id" type="hidden" name="persona_id" value="<?php echo $this->clienteArray["Id"] ?>" />
    <input id="volver_a_registrar_como_garante" type="hidden" name="volver_a_registrar_como_garante" value="1" />
</form>
<form style="margin: 0;" id="form_continuar_credito" method="GET" action="<?php echo $this->baseUrl("/usuarios/credito/registrar/") ?>">
    <input id="autoload" type="hidden" name="autoload" value="1" />
    <input id="garante_id" type="hidden" name="garante_id" value="<?php echo $this->clienteArray["Id"] ?>" />
    <input id="credito_a_renovar_id" type="hidden" name="credito_a_renovar_id" value="<?php echo $this->credito_a_renovar_id; ?>" />
</form>

<script type="text/javascript">
    $(function(){
        $('#btn_baja').click(function() {
            $.ajax({
                url: '<?php echo $this->baseUrl() ?>' + '/usuarios/cliente/baja',
                type: "POST",
                dataType: "json",
                data: { "id": <?php echo $this->clienteArray["Id"] ? $this->clienteArray["Id"] : 0 ?> },
                success: function(data) {
                    if (data.error == 1){
                        alert(data.mensaje);
                    } else {
                        location.reload();
                    }
                }
            });
            return false;
        });
        
        if ($.trim($("#cliente_id").val()) == "") {
            botonGuardar(true);
            botonActualizar(false);
            botonBorrar(false);
            botonObtenerDatos(false);
        } else { 
            botonActualizar(true);
            botonBorrar(true);
            botonObtenerDatos(true);
            botonGuardar(false)
        }
    });
</script>